package com.zzyl.nursing.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzyl.nursing.domain.NursingProject;
import com.zzyl.nursing.vo.CountByTimeMemberVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface NursingProjectMemberMapper extends BaseMapper<NursingProject> {


    @Select("select count(*) from reservation where status = 2\n" +
            "        and update_by = #{id} and update_time between #{startTime} and #{endTime}")
    Integer getCancelledReservationCount(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime, @Param("id") Long userId);


    @Select("select time, 6 - count(*) as count from reservation\n" +
            "    where time between #{startTime} and #{endTime}\n" +
            "    and status != 2 group by time")
    CountByTimeMemberVo getCountByTime(@Param("startTime") LocalDateTime startTime,@Param("endTime") LocalDateTime endTime);
}
